<template>
	<u-popup v-model="show" mode="center">
		<view class="pup_div">
			
			<vimage class="image" imgtype="1" src="static/images/hbbj1.png" mode="widthFix"></vimage>
			<view class="content">
				<scroll-view class="list" scroll-y>
					<view class="item" v-for="(item, i) in couponlist" :key="i">
						<vimage imgtype="1" class="image" src="static/images/card_bg1.png" mode="widthFix"></vimage>
						<view class="text_box">
							<view class="text_left">
								<view class="text_price">
									<text class="text">￥</text>
									<text class="lg_text text">{{ item.denomination }}</text>
								</view>
								<text class="text_tip">满{{ item.conditions }}元可以使用</text>
							</view>
							<view class="text_right" @click="receive"><text class="text">立即领取</text></view>
						</view>
					</view>
					<view class="item" v-if="obj.config && obj.config.amount > 0">
						<vimage class="image" imgtype="1" src="static/images/card_bg1.png" mode="widthFix"></vimage>
						<view class="text_box">
							<view class="text_left">
								<view class="text_price">
									<text class="lg_text text">{{ obj.config.amount }}</text>
									<text class="text">元</text>
								</view>
								<text class="text_tip">新手送礼,余额好礼</text>
							</view>
							<view class="text_right" @click="receive"><text class="text">立即领取</text></view>
						</view>
					</view>
					<view class="item" v-if="obj.config && obj.config.integral > 0">
						<vimage class="image"  imgtype="1" src="static/images/card_bg1.png" mode="widthFix"></vimage>
						<view class="text_box">
							<view class="text_left">
								<view class="text_price">
									<text class="lg_text text">{{ obj.config.integral }}</text>
									<text class="text">积分</text>
								</view>
								<text class="text_tip">新手送礼,积分好礼</text>
							</view>
							<view class="text_right" @click="receive"><text class="text">立即领取</text></view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</u-popup>
</template>

<script>
export default {
	data() {
		return {
			couponlist: [],
			obj: {
				config: {}
			},
			show: false
		};
	},
	mounted() {
		var _this = this;
		this.judgeLogin(
			() => {},
			() => {
				_this.getgift();
			}
		);
	},
	methods: {
		//新人送礼
		getgift() {
			this.$http('/receive', {}, 'GET').then(res => {
				if (res.data.msg && res.data.msg.coupon_data) {
					this.obj = res.data.msg;
					this.couponlist = this.obj.coupon_data;
					this.show = true;
				} else {
					this.show = false;
				}
			});
		},
		receive() {
			this.$http('/receive/' + this.obj.id, {}, 'POST').then(res => {
				uni.showToast({
					title: '领取成功。',
					icon: 'none'
				});
				this.show = false;
			});
		}
	}
};
</script>

<style lang="scss">
.pup_div {
	display: flex;
	flex-direction: column;
	width: 604rpx;
	> .image {
		width: 604rpx;
		height: 448rpx;
	}
	.content {
		background-image: linear-gradient(180deg, #ff6508, #ff3a00);
		padding-bottom: 32rpx;
		padding-top: 20rpx;
		border-radius: 0 0 20rpx 20rpx;
		.list {
			margin: 0 auto;
			width: 540rpx;
			background: #ffffff;
			border-radius: 20rpx;
			max-height: 440rpx;
			min-height: 200rpx;
			padding: 20rpx 0;
			scrollbar-width: none; /* firefox */
			-ms-overflow-style: none; /* IE 10+ */
			overflow-x: hidden;
			overflow-y: auto;
			&::-webkit-scrollbar {
				display: none; /* Chrome Safari */
			}
			.item {
				margin: 10rpx auto;
				width: 450rpx;
				position: relative;

				// height: 77px;
				.image {
					width: 450rpx;
				}
				.text_box {
					position: absolute;
					width: 100%;
					height: 100%;
					top: 16rpx;
					left: 34rpx;
					display: flex;
					width: 384rpx;
					height: 128rpx;

					.text_left {
						display: flex;
						flex-direction: column;

						width: 258rpx;
						height: 128rpx;
						align-items: center;
						justify-content: center;
						.text_price {
							display: flex;
							align-items: flex-end;
							.text {
								font-size: 26rpx;
								font-family: PingFang SC;
								font-weight: bold;
								color: #ff6658;
							}
							.lg_text {
								font-size: 64rpx;
								line-height: 1;
							}
							margin-bottom: 10rpx;
						}
						.text_tip {
							font-size: 24rpx;
							color: #999999;
						}
					}
					.text_right {
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: center;
						.text {
							display: block;
							width: 50rpx;
							height: 54rpx;
							font-size: 24rpx;
							font-weight: bold;
							color: #fb5648;
						}
					}
				}
			}
		}
	}
}
</style>
